/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/

#ifndef KERNEL_VFS_WFS_H__
#define KERNEL_VFS_WFS_H__

#include <stdint.h>

typedef struct
{
  char filename[58];
  uint16_t start_block;

  /* Given that the maximum size of a file is about 8MB, we use the top
   * 4 bits of the size field for flags.
   */
  uint32_t size;
} __attribute__((__packed__)) wfs_file_entry_t;

#define WFS_BLOCK_SIZE 512
#define WFS_N_FILES 64 /* 4 Kb, 8 x 512 byte block */
#define WFS_N_BLOCKS 16384

#define WFS_SIZE_MASK 0x0fffffff /* Mask to extract the size */
#define WFS_SIZE_IS_DIRECTORY (1 << 31) /* Is directory flag */

#define WFS_BLOCK_FREE 0x0
#define WFS_BLOCK_EOF 0xfffe

#define WFS_BLOCK_TABLE_START (WFS_N_FILES * sizeof(wfs_file_entry_t))
#define WFS_BLOCK_TABLE_SIZE (WFS_N_BLOCKS * sizeof(uint16_t))

#define WFS_DATA_START (WFS_BLOCK_TABLE_START + WFS_BLOCK_TABLE_SIZE)

void wfs_init(void);

#endif /* ! KERNEL_VFS_WFS_H */
